#!/usr/bin/env python3
# coding=utf-8

import time
import logging
from apscheduler.schedulers.background import BlockingScheduler


LOG_FORMAT = "%(asctime)s %(name)s %(levelname)s %(pathname)s %(message)s "#配置输出日志格式
DATE_FORMAT = '%Y-%m-%d  %H:%M:%S ' #配置输出时间的格式
logging.basicConfig(
    level = logging.DEBUG,
    format = LOG_FORMAT,
    datefmt = DATE_FORMAT,
    filename=r"/var/local/log/scheduler.log"
)


def myfunc(count):
    date = time.strftime(DATE_FORMAT, time.localtime())
    logging.info("scheduler" + str(count) + ":" + date)


if __name__ == "__main__":
    scheduler = BlockingScheduler()
    scheduler.add_job(myfunc, args=[1], trigger="interval", seconds=5)
    scheduler.add_job(myfunc, args=[2], trigger="cron", second="0")
    scheduler.start()
